<?php
class Category extends ActiveRecord\Model{
	
	static $table_name = 'categories';
	
    static $belongs_to = array(
        array('parent', 'foreign_key' => 'parent_id', 'class_name' => 'Category','order' => 'position asc')
   );

    static $has_many = array(
        array('children', 'foreign_key' => 'parent_id', 'class_name' => 'Category', 'order' => 'position asc')
    );


	public function get_topLevel()
	{
		return category::find('all',array('conditions'=>array('level_depth =? AND active=?','1','1')));
	}
	
	
}